%% Thie file main.m is the main to play the game nGames times
%%
clear;
%parameters
graphSize = inf;
timeLag = 2;
stay = true;   %if the ship can stay at a node, this is true
n = 2;          %for n-restricted graphs
graph = nRestrictedGraph(n,graphSize, timeLag, stay);
pShip = (sqrt(n*n+4)-n)/2;
nBombs = 1;     %number of bombs the bomber has
nGames = 1;   %number of games to be played
timeLimit = inf;
ship = 3; % 1=shipFerguson, 2=shipLeeLee, 3=shipStandStill
bomber = 2; % 1=bomberFerguson, 2=bomberGeneric, 3=bomberGeneric with pShip

%only for printing the graph
%print = biograph(graph);
%view(print) 

%store every single outcome, so we can perfrom statistics on it later
hit = zeros(nGames,1);          %hit(i) is true if the bomber hit the ship in the ith game
nDropped = zeros(nGames,1);     %nDropped(i) is the number of bombs that were dropped in the ith game
turn = zeros(nGames,1);         %turn(i) is the number of turns it took until game i was finished

%play the games
for i=1:nGames
    [h,nD,t] = game(graph, graphSize, pShip, nBombs, timeLag, n, timeLimit, ship, bomber);
    hit(i) = h;
    nDropped(i) = nD;
    turn(i) = t;
end

%do some statistics on the obtained data
hitMean = mean(hit)
hitStandardDeviation = std(hit)
nDroppedMean = mean(nDropped)
nDroppedStandardDeviation = std(nDropped)
turnMean = mean(turn)
turnStandardDeviation = std(turn)
[muhat, sighat, muci, sigci] = normfit(hit,0.05)
